﻿#ifndef PICTURERECTITEM_H
#define PICTURERECTITEM_H

#include <QGraphicsRectItem>
#include <QImage>

class PictureRectItem : public QGraphicsRectItem
{
public:
    explicit PictureRectItem(const QString &path, int index, bool match);
    ~PictureRectItem();

private:
    void init();

public:
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
    QRectF boundingRect() const override;
    QPainterPath shape() const override;

    inline QString path() { return mPicturePath; };
    inline int index() { return mPictureIndex; };
    inline int width() { return mSourceWidth; };
    inline int height() { return mSourceHeight; };
    inline int rotate() { return mSourceRotate; };
    inline bool matched() { return mMatchedFlag; };

private:
    QString mPicturePath;
    int mPictureIndex = -1;

    bool mMatchedFlag = true;

    int mSourceWidth = 0;
    int mSourceHeight = 0;

    float mSourceRotate = 0;

    // 图像
    QImage *mSourceImagetr = nullptr;

    // 边距
    uint8_t mContainMargin = 0;
};

#endif // PICTURERECTITEM_H
